package com.power.mock.mockprivate;

import com.alibaba.fastjson.JSON;
import com.google.inject.Inject;
import com.power.mock.User;
import com.power.mock.init.PowerInit;
import com.power.mock.util.WJedisHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author wangjianxin01
 */
public class UserService {
    private Logger logger = LoggerFactory.getLogger(this.getClass());

    public UserService() {
        PowerInit.injector.injectMembers(this);
    }

    {
        System.out.println("init");
    }

    @Inject
    private UserDAO userDAO;


    public void saveUser(User user) {
        logger.info("in method UserService.saveUser(User user), user = {}", user);
        String description = getUserDescription(user);
        user.setDescription(description);
    }



    private String getUserDescription(User user) {
        if (user.getAge() < 18) {
            return "未成年";
        }
        if (user.getAge() < 60) {
            return "青年";
        }
        return "老年";
        // 假如需要调用其他服务来获取描述呢
    }


}
